package advanced.practice._1002;

import java.util.Scanner;

public class Main {

    static String[]characters={"ling","yi","er","san","si","wu","liu","qi","ba","jiu"};
    static String[]unit={"Qian","","Shi","Bai"};
    public static void main(String...args){
        Scanner scanner=new Scanner(System.in);
        String number=scanner.next();
        if(number.startsWith("-")){
            System.out.print("Fu ");
            number=number.substring(1);
        }

        boolean hasPre=false;

        StringBuilder builder=new StringBuilder();

        if(number.length()>8){
            builder.append(characters[number.charAt(0)-'0']+" Yi ");
            number=number.substring(1);
            hasPre=true;
        }

        if(number.length()>4){
            builder.append(getNumberChars(number.substring(0,number.length()-4),hasPre,true)+" Wan ");
            hasPre=true;
            number=number.substring(number.length()-4);
        }
        builder.append(getNumberChars(number,hasPre,false));

        String result=builder.toString().trim();
        while (result.contains("ling Wan")) {
            result=result.replace("ling Wan", "Wan ling");
        }

        while(result.contains("ling ling")){
            result=result.replace("ling ling","ling");
        }


        if(result.endsWith(" ling")){
            result=result.substring(0,result.length()-5);
        }

        result=result.replace("Yi Wan","Yi");
        System.out.println(result);
    }

    static String getNumberChars(String num,boolean hasPre,boolean hasPost){

        StringBuilder builder=new StringBuilder();
        for(int i=0;i<num.length();i++){
            builder.append(characters[num.charAt(i)-'0']+" "+unit[(num.length()-i)%4]+" ");
        }
        String result=builder.toString().trim();

        result=result.replace("ling Qian","ling").replace("ling Bai","ling").replace("ling Shi","ling");

        while(result.contains("ling ling")){
            result=result.replace("ling ling","ling");
        }

        while (result.contains("  ")){
            result=result.replace("  "," ");
        }
        if(!hasPre&&result.startsWith("ling ")){
            result=result.substring(5);
        }

        if(result.endsWith(" ling")){
            result=result.substring(0,result.length()-5);
        }

        return result;
    }
}
